//Create function option
function OptionView(vWidth) {
    // Create a TableView.
    var self = Ti.UI.createTableView();
    self.backgroundColor = 'transparent';
    self.separatorColor = 'transparent';
    var rowTop = Ti.UI.createTableViewRow({
        height: '30'
    });
    var rowFunctionTitle = Ti.UI.createTableViewRow({
        height: 'auto'
    });
    var lblFunction = Ti.UI.createLabel({
        text: 'Calculate Stamp Duty for:',
        color: 'white',
        font: {
            fontSize: 20
        },
        height: 50,
        width: '90%',
        textAlign: 'center'
    });
    rowFunctionTitle.add(lblFunction);
    var rowFunction1 = Ti.UI.createTableViewRow({
        height: 'auto'
    });
    var btnFunc1 = Ti.UI.createButton({
        title: 'Lease & Rental',
        width: '90%',
        id:'btnFunc1'
    });
    rowFunction1.add(btnFunc1);
    var rowFunction2 = Ti.UI.createTableViewRow({
        height: 'auto'
    });
    var btnFunc2 = Ti.UI.createButton({
        title: 'Sales & Purchase',
        width: '90%',
        id:'btnFunc2'
    });
    rowFunction2.add(btnFunc2);
    var rowFunction3 = Ti.UI.createTableViewRow({
        height: 'auto'
    });
    var btnFunc3 = Ti.UI.createButton({
        title: 'Mortgage',
        width: '90%',
        id:'btnFunc3'
    });
    rowFunction3.add(btnFunc3);
    var rowBlank = Ti.UI.createTableViewRow({
        height: '30'
    });
    // Populate the TableView data.
    var data = [rowTop, rowFunctionTitle, rowBlank, rowFunction1, rowBlank, rowFunction2, rowBlank, rowFunction3];
    self.setData(data);
	self.addEventListener('click', function(e) {
		if (e.source.id === 'btnFunc1') {
			btnFunc1Press();
		} else{
			if (e.source.id === 'btnFunc2') {
				btnFunc2Press();
			} else{
				if (e.source.id === 'btnFunc3') {
					btnFunc3Press();
				} else{
					Ti.API.info(e.source);
				};
			};
		};
    });
    
    function btnFunc1Press() {
    	// self.setData([])
    	self.visible = false;
        Ti.App.fireEvent('chooseFunction', {
            info: 1
        });
    }

    function btnFunc2Press() {
        Ti.App.fireEvent('chooseFunction', {
            info: 2
        });
    }

    function btnFunc3Press() {
        Ti.App.fireEvent('chooseFunction', {
            info: 3
        });
    }
    return self;
}
module.exports = OptionView;